cmake_minimum_required(VERSION 2.8)

project(FoxCannon)

find_package(MPI REQUIRED)

include_directories(${MPI_INCLUDE_PATH} ${FoxCannon_SOURCE_DIR}/include ${FoxCannon_SOURCE_DIR}/src)
link_directories( ${FoxCannon_SOURCE_DIR}/lib )

file(GLOB SRC_LIST ${FoxCannon_SOURCE_DIR}/src/*.cpp ${FoxCannon_SOURCE_DIR}/src/*.h)
aux_source_directory(./test TEST_LIST)

add_executable(${PROJECT_NAME} ${SRC_LIST})
target_link_libraries(${PROJECT_NAME} ${MPI_LIBRARIES})

add_executable(testing ${TEST_LIST})
target_link_libraries(testing UnitTest++ ${MPI_LIBRARIES})

add_test(test testing)

#if(MPI_COMPILE_FLAGS)
#    set_target_properties(${PROJECT_NAME} PROPERTIES
#        COMPILE_FLAGS "${MPI_COMPILE_FLAGS}")
#endif()

#if(MPI_LINK_FLAGS)
#    set_target_properties(${PROJECT_NAME} PROPERTIES
#        LINK_FLAGS "${MPI_LINK_FLAGS}")
#endif()

# add a target to generate API documentation with Doxygen
find_package(Doxygen)

if(DOXYGEN_FOUND)
    add_custom_target(doc
        ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile
        WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
        COMMENT "Generating API documentation with Doxygen" VERBATIM
    )
endif(DOXYGEN_FOUND)
